package com.meefo.meeting.common;


import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

//sqlSessionFactory -> sqlSession
public class MybatisUtils {
    private static SqlSessionFactory sqlSessionFactory_1;

    static {
        System.out.println("==============加载数据源==============");
        try {
            //数据库-meeting
            String resource_1 = "mybatis-config_1.xml";
            InputStream inputStream_1 = Resources.getResourceAsStream(resource_1);
            sqlSessionFactory_1 = new SqlSessionFactoryBuilder().build(inputStream_1);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static SqlSession getSqlSession_1() {
        return sqlSessionFactory_1.openSession(true);
    }

}